package com.siyuanren.gcocp.enums.wx;

import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 期末测试学分
 * @author PVer
 */
public enum FinalTestEnum {
    FINAL_TEST_0("测试成绩小于60分，不获得学分；", 1, 0),
    FINAL_TEST_60("测试成绩大于等于60分，可加6分；", 2, 6.0),
    FINAL_TEST_80("测试成绩大于等于80分，可加12分；", 3, 12.0),
    FINAL_TEST_90("测试成绩大于等于90分，可加16分；", 4, 16.0),
    FINAL_TEST_100("测试成绩等于100分，可加20分；", 5, 20.0);

    private String desc;
    private int value;
    private double score;


    FinalTestEnum(String desc, int value, double score) {
        this.desc = desc;
        this.value = value;
        this.score = score;
    }

    public static FinalTestEnum getModel(int value) {
        for (FinalTestEnum he : FinalTestEnum.values()) {
            if (Objects.equals(value, he.getValue())) {
                return he;
            }
        }
        return null;
    }

    public static String getEnumDesc(Integer value) {
        if (value == null) {
            return StringUtils.EMPTY;
        }
        FinalTestEnum model = getModel(value);
        if (model == null) {
            return StringUtils.EMPTY;
        }
        return model.getDesc();
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }
}